#!/bin/bash
PATH="/opt/java/jdk1.8.0_151/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
echo "======================to do transform=========================="
cd docker-hive
echo "transform in background"
docker-compose exec -d hive-server env LANG=C.UTF-8 bash -c '/opt/hive/bin/beeline -u jdbc:hive2://localhost:10000 -e "insert overwrite table ads_wms.financial_info
select ro.record_year record_year,
income,
outcome,
income - outcome benefit
from (select year(in_time) record_year, sum (in_price * in_count) outcome
from ods_wms.record_in
group by year(in_time)) ro
join
(select year(out_time) record_year, sum (out_price * out_count) income
from ods_wms.record_out
group by year(out_time)) ri
on ro.record_year = ri.record_year;"'
